package com.booksys.service.Impl;

import com.booksys.mapper.VisitedDao;
import com.booksys.pojo.Visited;
import com.booksys.pojo.VisitedExample;
import com.booksys.pojo.VisitedWithBLOBs;
import com.booksys.service.VisitedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VisitedServiceImpl implements VisitedService {
    @Autowired
    private VisitedDao visitedDao;

    @Override
    public Visited insertVisited(Visited visited) {
        visitedDao.insertSelective((VisitedWithBLOBs) visited);
        return visited;
    }

    @Override
    public List<Visited> queryVisited(int userId, int provinceId) {
        VisitedExample visitedExample = new VisitedExample();
        VisitedExample.Criteria criteria = visitedExample.createCriteria();

        criteria.andUserIdEqualTo(userId);
        criteria.andProvinceIdEqualTo(provinceId);

        List<Visited> list = visitedDao.selectByExample(visitedExample);
        return list;
    }
}
